<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var setZeroes = function(matrix) {
        console.log(matrix.length)
        console.log(matrix[0].length)
        // 定义 m * n;
        const m = matrix.length;
        const n = matrix[0].length;
        let mapX = new Map();
        let mapY = new Map();
        // 遍历存到map里面
        for(let i = 0; i < m; i++) {
            for(let j = 0; j < n; j++) {
                if(matrix[i][j] === 0) {
                    mapX.set(i,i);
                    mapY.set(j,j);
                }
            }
        }
        // 处理x轴的
        for(let i of mapX.keys()) {
            for(let j = 0; j < n; j++) {
                console.log(i,j)
                matrix[i][j] = 0;
            }
        }
        // 处理y轴的
        for(let i of mapY.keys()) {
            for(let j = 0; j < m; j++) {
                console.log(matrix[j][i])
                // matrix[i][j] = 0;
            }
        }
        return matrix;
    };
    console.log(setZeroes([[1, 1, 1], [1, 0, 1], [1, 1, 1]]));
    // console.log(setZeroes([[0,1,2,0],[3,4,5,2],[1,3,1,5]]));
    // console.log(setZeroes([[0,1]]));
</script>
</body>
</html>
